let { db }  = require('../tools')

module.exports = ( req, res ) => {
    let { username, password } = req.body
    db.collection('page')
        .findOne({ username, password })
            .then(({ username }) => {
                req.session.username = username;
                res.json({ erron: 0, data: username })
            })
            .catch(err => res.json({ errno: 1 }))

}